<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>登陆</title>
  <script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/jquery"></script>
  <script src="__PUBLIC__/script/common.js" common-data-1="{:U('Mix/dest')}"></script>
  <script src="__PUBLIC__/script/jquery-weui/dist/js/jquery-weui.min.js"></script>
  <link rel="stylesheet" href="__PUBLIC__/script/jquery-weui/dist/lib/weui.min.css">
  <link rel="stylesheet" href="__PUBLIC__/script/jquery-weui/dist/css/jquery-weui.min.css">
  <link rel="stylesheet" href="__PUBLIC__/styles/base.css">
  <link rel="stylesheet" href="__PUBLIC__/styles/index.css">
</head>
<body>
  <div class="container">
    <div class="logo">
      <img src="__PUBLIC__/res/logo.png" alt="logo">
    </div>
    <div class="login">
      <form autocomplete="off" action="{:U('Wchat/wechat_login')}" method="post" id="normal">
        <input type="tel" autocomplete="off" name="web_phone" id="index_phone" placeholder="手机号码" form='normal' onchange="changeNext(this)"><br>
        <input type="password" autocomplete="off" name="web_pass" id="index_pass" placeholder="密码" form='normal' onchange="changeNext(this)"><br>
        <input type="hidden" name="state" value="" id="state">
        <input type="submit" id = "index_submit1" value="登录" onclick="postIt(0, event)">
        <input type="submit" id = "index_submit0" value="绑定登陆登录" onclick="postAuthIt(1, event)">
      </form>
    </div>
    <div class="more flex">
      <div class="float_left"><a href="{:U('Mix/post_from_frg')}">忘记密码</a></div>
      <div class="float_right"><a href="{:U('Wchat/signup')}">注册</a></div>
      <div class="float_clear"></div>
    </div>
  </div>
  <div class="bottomMess"><span>深圳市東源匯信息科技有限公司</span></div>
  <div style='height:1vh;width:100vw;'></div>
  <script id="mock_script">
    // Mock.mock()
  </script>
  <script>
    $(document).ready(() => {
      // 目标形式
      // http://pgl.oaio.online/index.php/web/wchat/login/wechat_id/7
      if (/&&wechat_id=(\d{1,})/.test(location.href.toLowerCase())) {
        const index = Number.parseInt(location.href.toLowerCase().match(/&&wechat_id=(\d{1,})/)[1])
        localStorage.clear()
        localStorage.setItem('login_index', `${index}`)
        localStorage.setItem('login', `http://pgl.oaio.online/index.php/web/wchat/login/wechat_id/${index}`)
        location.href = `http://pgl.oaio.online/index.php/web/wchat/login/wechat_id/${index}`
      } else if (/\/wechat_id\/(\d{1,})/.test(location.href.toLowerCase())) {
        const index = Number.parseInt(location.href.toLowerCase().match(/\/wechat_id\/(\d{1,})/)[1])
        localStorage.clear()
        localStorage.setItem('login_index', `${index}`)
        localStorage.setItem('login', `http://pgl.oaio.online/index.php/web/wchat/login/wechat_id/${index}`)
      } else if (!/\/wechat_id\/(\d{1,})/.test(location.href.toLowerCase()) && !/&&wechat_id=(\d{1,})/.test(location.href.toLowerCase()) && localStorage.getItem('login')) {
        location.href = localStorage.getItem('login')
      } else if (!/\/wechat_id\/(\d{1,})/.test(location.href.toLowerCase()) && !/&&wechat_id=(\d{1,})/.test(location.href.toLowerCase()) && !localStorage.getItem('login')) {
        $.alert(`请从公众号点击打开本网站, 继续使用网站可能导致不可预知错误！${location.href.toLowerCase()}`, "警告");
      } else {
        $.alert(`请从公众号点击打开本网站, 继续使用网站可能导致不可预知错误！${location.href.toLowerCase()}`, "警告");
      }
    })
    function postIt (state, evt) {
      $('#state').val(state)
      sessionStorage.clear()
      if (String($('#index_phone').val()).replace(/[\s\D]/g, '') === '' || String($('#index_pass').val()) === '') {
        $.toptip(`请先填写手机号与密码`, 20000, 'error')
        evt.preventDefault()
        evt.stopPropagation()
        try {
          event.preventDefault()
          event.stopPropagation()
        } catch (err) {
          console.log(err)
        }
        throw new Error(`不允许空密码`)
        return false
      }
      $(`#normal`).submit()
    }
    function postAuthIt (state, evt) {
      $('#state').val(state)
      if (String($('#index_phone').val()).replace(/[\s\D]/g, '') === '' || String($('#index_pass').val()) === '') {
        $.toptip(`请先填写手机号与密码`, 'error')
        evt.preventDefault()
        evt.stopPropagation()
        try {
          event.preventDefault()
          event.stopPropagation()
        } catch (err) {
          console.log(err)
        }
        throw new Error(`不允许空密码`)
        return false
      }
      let q = window.confirm()
      if(q) $(`#normal`).submit()
    }
    $(document).ready(() => {
      window.HeightRemote = $(window).height()
      $(window).on('resize', (evt) => {
        if($(window).height() < window.HeightRemote) {
          $(`.bottomMess`).css('display', 'none')
        } else {
          $(`.bottomMess`).css('display', 'block')
        }
      })
    })
  </script>
</body>
</html>